package crazy.crack;

/*
Write code to reverse a C-Style String  (C-String means that “abcd” is represented as 
five characters, including the null character )
*/
public class Cstyle {
	
	public char[] reverse(char[] string){
		
		int n  = string.length- 1;
		for(int i = 0; i <= (n - 1) / 2; i ++){
			char temp1 = string[i];
			char temp2 = string[n - 1 - i];
			string[i] = temp2;
			string[n - 1 - i] = temp1;
		}
		return string;
	}
	
	public static void main(String[] args) {
		Cstyle m = new Cstyle();
		String s1 = "abcdeajsdfkljasdklfjkaldsfjkl\0";
		String s2 = "abcdadsfaksdfjksadfjkaksjdfjas\0";
		char[] cs1 = s1.toCharArray();
		char[] cs2 = s2.toCharArray();
		System.out.println(m.reverse(cs1));
		System.out.println(m.reverse(cs2));
	}

}